package com.suoluo.zenadmin.dao.country;

import java.util.List;
import java.util.Map;

import net.paoding.rose.jade.annotation.DAO;
import net.paoding.rose.jade.annotation.SQL;

import com.suoluo.zenadmin.vo.country.ContinentVO;
import com.suoluo.zenadmin.vo.country.CountryVO;
@DAO
public interface CountryDAO {

	@SQL("SELECT t_country_id countryId,t_country_name countryName,t_country_orig_flag countryOrigFlag," +
					"t_country_name_en countryNameEn,t_country_name_zh countryNameZh,t_continent_name continentName from " +
					"tb_country tc join tb_continent tb on tc.t_continent_id = tb.t_continent_id " +
					"order by t_country_id desc limit :1,:2")
	@SuppressWarnings("rawtypes")
	public List<Map> findListCountry(int startPage,int rows);
	@SQL("select count(t_country_id) from tb_country")
	public int findCountryCount();
	@SQL("insert into tb_country(t_country_name,t_continent_id,t_country_orig_flag,t_country_sort," +
			"t_country_name_en,t_country_name_zh)" +
			" values(:1.countryName,:1.continentId,:1.countryOrigFlag,:1.countrySort,:1.countryNameEn,:1.countryNameZh)")
	public void insert(CountryVO country);
	@SQL("SELECT * FROM tb_continent")
	public List<ContinentVO> findListContinent();
	@SQL("select * from tb_country where t_country_id = :1")
	public CountryVO findCountryById(int countryId);
	@SQL("update tb_country set t_country_name=:1.countryName,t_country_name_en=:1.countryNameEn," +
			"t_country_name_zh=:1.countryNameZh,t_country_sort=:1.countrySort,t_country_orig_flag=:1.countryOrigFlag,t_continent_id=:1.continentId" +
			"  where t_country_id =:1.countryId")
	public void update(CountryVO country);
	@SQL("delete from tb_country where t_country_id=:1")
	public void delete(int countryId);
	@SQL("select sum(res) from " +
					"(SELECT count(dest_id) res from tb_dest where country_id =:1 " +
					"union all " +
					"select count(news_id) res from tb_news2  where country_id=:1) resCountry")
	public int findCountryForeignDestAndNews(int countryId);
}
